﻿#region

using System.Xml;
using System.Xml.Serialization;

#endregion

namespace MISMO.org
{
    public class SerializationHelper<T>
    {
        public static void Serialize(T toSerialize, string fileName)
        {
            var serializer = new XmlSerializer(typeof (T));
            using (var xmlWriter = XmlWriter.Create(fileName))
            {
                serializer.Serialize(xmlWriter, toSerialize);
            }
        }

        public static T Deserialize(string fileName)
        {
            var serializer = new XmlSerializer(typeof(T));
            using (var xmlReader = XmlReader.Create(fileName))
            {
                return (T)serializer.Deserialize(xmlReader);
            }
        }

    }
}